package ishitong.vehicleManagement.service.biz.impl;

import ishitong.vehicleManagement.dao.FakePlateVehicleDao;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.ishitong.platform.common.page.Page;
import java.util.List;
import ishitong.vehicleManagement.model.FakePlateVehicle;
import ishitong.vehicleManagement.model.FakePlateVehicleQuery;
import ishitong.vehicleManagement.service.biz.FakePlateVehicleService;

/** @pdOid 3d25cb1a-75b6-4cc3-b60a-a2376507f15f
 * @创建日期:2013-09-27 12:15:23
 * 
 * @功能描述:RVIMS_FakePlateVehicle业务服务
 * @开发人员:福建视通 */
@Service(value="fakePlateVehicleService")
@Transactional
public class FakePlateVehicleServiceImpl implements FakePlateVehicleService {
   /** @pdOid cc56c754-6aa0-4d6d-b752-053082ab51b9
       @pdRoleInfo migr=yes name=FakePlateVehicleDao assc=association1 */
   @Autowired
   private FakePlateVehicleDao fakePlateVehicleDao;
   /** @pdOid be8ec2b6-97d3-4372-8d68-02c771c41b89
       @pdRoleInfo migr=yes name=SPIVehicleService assc=association7 */
   @Autowired
   private SPIVehicleService spiVehicleService;
   /** @pdOid e252da4c-2359-4179-858f-edb2b0acccf1
       @pdRoleInfo migr=yes name=SPISysCodeService assc=association10 */
   @Autowired
   private SPISysCodeService spiSysCodeService;
   
   /** @param fpv
    * @pdOid 603d14f2-7902-4fab-b0f8-9a1790fca8eb */
   private void setFakePlateVehicleProperty(FakePlateVehicle fpv) {
   	   fpv.setPlateColor(spiSysCodeService.getSysCodeById( fpv.getPlateColorId()));
   	   fpv.setPlateType(spiSysCodeService.getSysCodeById(fpv.getPlateTypeId()));
   	   fpv.setUsingCharacter(spiSysCodeService.getSysCodeById(fpv.getUsingCharacterId()));
   	   fpv.setVehicleClassification(spiSysCodeService.getSysCodeById(fpv.getVehicleClassificationId()));
   	   fpv.setVehicleColor(spiSysCodeService.getSysCodeById(fpv.getVehicleColorId()));
   	   fpv.setVehicleType(spiSysCodeService.getSysCodeById(fpv.getVehicleTypeId()));
      }
   
   /** @param id
    * @pdOid d124315e-0848-4d25-a7e2-efe4c25f1892
    * @功能描述: 删除RVIMS_FakePlateVehicle
    * @异常类型: */
   public void delete(String id) {
   	if(id!=null&&!id.trim().equals("")){
   		String[] idList=id.split(";");
   		for(int i=0;i<idList.length;i++){
   			if(idList[i]!=null&&!idList[i].trim().equals("")){
   				this.fakePlateVehicleDao.remove(idList[i]);
   			}
   		}
   	}
   }
   
   /** @param fakePlateVehicle
    * @pdOid c3aac668-6fbf-491e-9ffe-c7a7b3f73b8c
    * @功能描述: 删除RVIMS_FakePlateVehicle
    * @异常类型: */
   public void deleteByModel(FakePlateVehicle fakePlateVehicle) {
   	this.fakePlateVehicleDao.remove(fakePlateVehicle);
   }
   
   /** @param id
    * @pdOid 8ba8cfad-84d6-4849-9d3e-19b2cf9f664f
    * @功能描述: 查询RVIMS_FakePlateVehicle
    * @异常类型: */
   public FakePlateVehicle findById(String id) {
    FakePlateVehicle fakePlateVehicle = this.fakePlateVehicleDao.findByPrimaryKey(id);
    setFakePlateVehicleProperty(fakePlateVehicle);
   		return fakePlateVehicle;
   }
   
   /** @param fakePlateVehicle
    * @pdOid 8db46849-da62-430f-8736-d1620e865ccb
    * @功能描述: 新增与修改RVIMS_FakePlateVehicle
    * @异常类型: */
   public void save(FakePlateVehicle fakePlateVehicle) {
   	this.fakePlateVehicleDao.save(fakePlateVehicle);
   }
   
   /** @param query 
    * @param pageSize 
    * @param pageNum
    * @pdOid 8cf14da9-7d80-4bdb-9d60-853cf052b52b
    * @功能描述: 通过FakePlateVehicleQuery对象，查询RVIMS_FakePlateVehicle
    * @异常类型: */
   public Page findPage(FakePlateVehicleQuery query, int pageSize, int pageNum) {
    Page<FakePlateVehicle> page = this.fakePlateVehicleDao.findPage(query,pageSize,pageNum);
     List<FakePlateVehicle> lst = page.getResults();
     for (FakePlateVehicle fpv: lst) {
     	setFakePlateVehicleProperty(fpv);
     }
   	return page;
   }
   
   /** @param query
    * @pdOid 2599697b-df5d-4636-982d-75220125f97e
    * @功能描述: 通过FakePlateVehicleQuery对象，查询RVIMS_FakePlateVehicle
    * @异常类型: */
   public List<FakePlateVehicle> findList(FakePlateVehicleQuery query) {
   	return this.fakePlateVehicleDao.findList(query);
   }

}